import Mock from 'mockjs'
import store from '../store/index'
/**
 * 模拟 GET 请求 '/mock/api/v1/list' 资源
 */
Mock.mock(/\/mock\/login.*/, 'post', (options: any) => {

 
   console.log(store.state.newusers)
  const userlist =store.state.newusers
  const body = JSON.parse(options.body)
  const  flag:any = userlist.filter(item => {
    if (item.username === body.username &&item.password === body.password) { 
      return item
    }
  })
  const data = Mock.mock({
    token: 123456789,
    options: flag[0],
    message: '登录成功',
  })
  if(flag[0]){
    return {
      data,
      code: 200,
      message: '请求登录成功',
    }
  }else{
    return {
      code: 400,
      message: '登录失败，账号名或密码错误',
    }
  }
})



